<script>
	$(document).ready(function ()
	{
		$('#data').dataTable( {
			"sPaginationType": "full_numbers",
			"aaSorting": [[ 0, "desc" ],[ 1, "asc"],[ 2, "asc"],[ 3, "asc"],[ 4, "asc"]]
		});
	});
</script>
<fieldset>
	<div class="productsinstances index">
		<h2><?php echo __('Product Used'); ?></h2>
		<div class="newbutton">
			<ul>
				<li><?php echo $this->Html->link(__('Record Product Used'), array('action' => 'choosesupplier')); ?></li>
				<li><?php echo $this->Html->link(__('Record Product Used Using Barcode'), array('action' => 'recordbarcode')); ?></li>
			</ul>
		</div>
		<br><br>
		<table id="data" class="table" cellpadding="0" cellspacing="0"  border="0">
			<thead>
				<tr>
					<th>Date of Removal</th>
					<th>Brand</th>
					<th>Range</th>
					<th>Category</th>
					<th>Item</th>
					<th>Barcode</th>		
					<th>Removed</th>
					<th>Removal Reason</th>
					<th class="actions"><?php echo __('Actions'); ?></th>
				</tr>
			</thead>

			<tbody>
				<?php foreach ($productsinstances as $productsinstance): ?>
					<tr>
						<td><?php echo h($productsinstance['Productsinstance']['doc']); ?></td>
						<td><?php echo h($brand[$productsinstance['Product']['productsbrands_id']]); ?></td>
						<td>
							<?php if(!empty($range[$productsinstance['Product']['productsranges_id']])){echo h($range[$productsinstance['Product']['productsranges_id']]);} ?>
						</td>
						<td>
							<?php if(!empty($category[$productsinstance['Product']['productscategories_id']])){echo h($category[$productsinstance['Product']['productscategories_id']]);} ?>
						</td>
						<td><?php echo h($productsinstance['Product']['description']); ?></td>
						<td><?php echo h($productsinstance['Product']['barcode']); ?></td>
						<td><?php echo h($productsinstance['Productsinstance']['number_removed']); ?></td>
						<td><?php echo h($productsinstance['Removalreason']['name']); ?></td>

						<td class="actions">
							<?php echo $this->Html->link(__('Edit'), array('action' => 'edit', $productsinstance['Productsinstance']['id'])); ?>
							<?php echo $this->Html->link(__('View Products'), array('controller' => 'products' ,'action' => 'view', $productsinstance['Product']['id'])); ?>
							<?php echo $this->Form->postLink(__('Archive'), array('action' => 'delete', $productsinstance['Productsinstance']['id']), null, __('Are you sure you want to archive product used for product %s on %s?', $productsinstance['Product']['id'],$productsinstance['Productsinstance']['doc'])); ?>
						</td>
					</tr>
				<?php endforeach; ?>
			</tbody>
		</table>

	</div>

</fieldset>		